import 'dart:convert';
import 'dart:io';
import 'dart:ui';

import 'package:dio/dio.dart';
import 'package:flutter/cupertino.dart';
import 'package:xiongan_app_yy/net/internet_api.dart';

class ImageDownloadUtil {
  static Future<String> getImageBase64(String s, Function callBack) {
    InternetAPI.getInstance().post(
      "FileUpload/File/DownFlie",
      (data) {
        callBack(data);
      },
      params: {"filePath": s},
      options: new Options(
          contentType: ContentType.parse("application/x-www-form-urlencoded")),
    );
  }

  static Widget isImageType(String image) {
    if (image == "assets/images/build.png") {
      return Image.asset(image, fit: BoxFit.fill);
    } else {
      return Image.memory(
        //base64.decode(image),
        base64Decode(image),
        height: 80,
        width: 80,
        fit: BoxFit.fill,
        gaplessPlayback: true, //防止重绘
      );
    }
  }
}
